﻿#include "collectioncontent.h"
#include "ui_collectioncontent.h"
#include <QDebug>

CollectionContent::CollectionContent(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CollectionContent)
{
    ui->setupUi(this);

    m_saveInfo = GlobalVars::g_localSave;
    setWindowShow();
}

CollectionContent::~CollectionContent()
{
    delete ui;
}

void CollectionContent::setWindowShow()
{
    ui->lb_type->setText(m_saveInfo.getHotelType());
    ui->lb_location->setText(m_saveInfo.getLocation());
    ui->pb_hotelName->setText(m_saveInfo.getHotelName());
    ui->lb_num->setText(m_saveInfo.getStar() + "分");

    double mark = m_saveInfo.getStar().toDouble();
    if (mark == 5.0)
    {
        ui->lb_star->setText("★★★★★");
    }else if (mark >= 4)
    {
        ui->lb_star->setText("★★★★☆");
    }
    else if (mark >= 3)
    {
        ui->lb_star->setText("★★★☆☆");
    }else if (mark >= 2)
    {
        ui->lb_star->setText("★★☆☆☆");
    }else
    {
        ui->lb_star->setText("★☆☆☆☆");
    }
}

void CollectionContent::setImage(const QImage& image)
{
    ui->lb_image->setPixmap(QPixmap::fromImage(image.scaled(170,100)));
}

void CollectionContent::on_pb_delete_clicked()
{
    emit signalDeleteSaveHotel(m_saveInfo.getSave());
}

void CollectionContent::on_pb_hotelName_clicked()
{
    emit signalGainHotelDetails(m_saveInfo.getHotel());
}

QString CollectionContent::getSaveId()
{
    return m_saveInfo.getSave();
}
